package com.ghsc.ghxc.jsb.ui.my.activity

import com.cn.appcore.base.BaseVMActivity
import com.cn.appcore.ext.getCompatColor
import com.cn.appcore.ext.setSingleClickListener
import com.cn.appcore.ext.showToast
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.config.CustKey
import com.ghsc.ghxc.jsb.config.LoginHelper
import com.ghsc.ghxc.jsb.databinding.ActivityLogOffBinding
import com.ghsc.ghxc.jsb.view.ConfirmCancelPopViiew
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.enums.PopupAnimation

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.my.activity
 * 类名：LogOffActivity
 * 创建时间：2024/4/25 18:01
 * 创建人 @author： xiaolin
 * 描述 ：Todo...账号注销
 */
class LogOffActivity  : BaseVMActivity<SetUpViewModel, ActivityLogOffBinding>() {
    override fun attachLayoutRes(): Int {
        return R.layout.activity_log_off
    }

    override fun attachVMClass(): Class<SetUpViewModel>? {
        return SetUpViewModel::class.java
    }

    override fun initBar() {
        super.initBar()
        mImmersionBar!!.statusBarDarkFont(true).init()
    }
    var tvCon = ""
    override fun initView() {
        binding.bar.topLeftView.setSingleClickListener { finish() }
        binding.bar.topTitle.text = "账号注销"
        mViewModel.onZhuXiaoIndexMethod("")
    }

    override fun initClickListener() {
        super.initClickListener()
        binding.tvBtnOut.setSingleClickListener {
            XPopup.Builder(this@LogOffActivity)
                .popupAnimation(PopupAnimation.ScaleAlphaFromCenter  )
                .customHostLifecycle(lifecycle)
                .navigationBarColor(getCompatColor(R.color.bg_dark_color))
                .asCustom(
                    ConfirmCancelPopViiew(this@LogOffActivity,"提示",tvCon,
                        btnConfirm={
                            mViewModel.onZhuXiaoMethod("")
                        },
                        btnCancel={
                        },)
                )
                .show()
        }
    }
    override fun initRequestObserver() {
        super.initRequestObserver()
        mViewModel.apply {

            errorMsg.observe(this@LogOffActivity) {
                showToast(it)
            }
            againLoginMsg.observe(this@LogOffActivity) {
                showToast(CustKey.IN_AGAIN_MSG)
                LoginHelper.startLoginPage()
            }
            onZhuXiaoData.observe(this@LogOffActivity) {
                showToast(it.data.data.msg)
                LoginHelper.startLoginPage()
            }
            onZhuXiaoIndexData.observe(this@LogOffActivity) {
                binding.tvTiXing.text = it.data.data.tixing
                binding.tvTiaoJian.text=it.data.data.tiaojian
                tvCon=it.data.data.tanchuang
            }
        }
    }
}